﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace EFong.Contract
{
    [DataContract]
    public class BankAccount
    {
        private Guid _id = Guid.NewGuid();
        [DataMember]
        public Guid ID
        {
            get { return _id; }
            set { _id = value; }
        }

        private string _name = string.Empty;
        [DataMember]
        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }

        private bool _effective = true;
        [DataMember]
        public bool Effective
        {
            get { return _effective; }
            set { _effective = value; }
        }

        private decimal _amount;
        [DataMember]
        public decimal Amount
        {
            get { return _amount; }
            set { _amount = value; }
        }

        public decimal? CNYAmount
        {
            get 
            {
                if (Currency == null)
                    return null;
                if (Currency.Code == "CNY")
                    return null;
                return this.Amount * this.Currency.ExchangeRate;
            }
        }

        private Currency _currency;
        [DataMember]
        public Currency Currency
        {
            get { return _currency; }
            set { _currency = value; }
        }

        private bool _canNegative = false;
        [DataMember]
        public bool CanNegative 
        {
            get { return _canNegative; }
            set { _canNegative = value; }
        }

        private string _returnDay = string.Empty;
        [DataMember]
        public string ReturnDay 
        {
            get { return _returnDay; }
            set { _returnDay = value; }
        }

        private bool _isNew = true;
        [DataMember]
        public bool IsNew
        {
            get { return _isNew; }
            set { _isNew = value; }
        }

        public override bool Equals(object obj)
        {
            BankAccount temp = obj as BankAccount;
            if (temp == null)
                return false;
            return (this.ID.Equals(temp.ID));
        }

        public override string ToString()
        { 
            return this.Name;
        }
    }
}
